<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<html>
<head>
    <meta charset="UTF-8">
    <title>图书列表</title>
    <meta name="viewport" content="width=device-width,initial-scale=1"/>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        .box{
            width:100%;
            height:46px;
            background-color:lightskyblue;
            box-shadow: 1px 1px 1px #E0E0E0;
            margin-bottom: 2px;
        }
        .box_center{
            width:1200px;
            height: 100%;
            margin: 0 auto;

        }
        a{
            text-decoration:none;
        }

        .box_center_b{
            width:100%;
            height: 45px;

        }
        .box_center_b ul{
            margin-left: 200px;
            text-align: center;

        }
        .box_center_b li{
            list-style:none;
            float:left;
            margin-left:80px;
            color:#666;
            font-family: "微软雅黑";
            font-size: 16px;
            margin-top: 19px;

        }

        .box_center_b a {
            width: 100px;
            height: 28px;
            color: #666;
            text-align: center;
        }
        .box_center_b a:hover {
            cursor:pointer;
            color:#136fb8;
            text-align: center;
            text-decoration: none;
            border-bottom: 1px solid #136fb8;
        }

        .a2{
            /*float:left;*/
            /*line-height: 5px;*/
            margin-top: 0px;
        }
        .box1{
            width: 500px;
            height:50px;
            margin: 0 auto;
        }
        .box2{

            width: 300px;
            float: left;
            margin-left: 20px;

            border:1px solid #dddddd;
        }
        .box2 li{
            list-style: none;
            margin-left:80px;
            color:#666;
            font-family: "微软雅黑";
            font-size: 16px;
            margin-top: 20px;
            line-height: 40px;
        }
        .box2 a{
            margin-left:80px;
            color:#666;
            font-family: "微软雅黑";
            font-size: 16px;
            margin-top: 20px;
        }
        .box2_b{
            width: 100%;
            height: 300px;

        }
        .box2_b img{
            margin-top: 20px;
        }
        .box2_bb{
            margin-top: 20px;

        }
        .box2_bb p{
            color: #FF6700;
            line-height: 20px;
            margin-left: 20px;
            margin-top: 20px;
        }
        .box3{
            margin-left: 20px;
            width: 1000px;
            float: left;
        }

    </style>
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery-3.2.1.js" ></script>
    <script>
        $(function(){
            $(".but").click(function(){
                $.ajax({
                    type:"get",
                    url:"addcar",
                    async:true,
                    data:"bookid="+$(".bookid").val(),
                    success:function(result){
                        var obj = JSON.parse(result);
                        if(obj.message=="true"){
                            alert("success")
                        }else{
                            window.location.href=obj.url;
                            alert("false")
                        }
                    }
                });
            });
        });
    </script>
</head>
<body>
<div class="box">
    <div class="box_center">
        <a class="a2" style="line-height: 50px;margin-right: 50px" href="index">首页</a>
        <a class="a2"  style="line-height: 50px" href="shoplist">购物车</a>
        <c:if test="${user.role=='1'}">
            <a class="a2"  style="line-height: 50px;margin-left: 10px" href="/toGoods">商品管理</a>
            <a class="a2"  style="line-height: 50px;margin-left: 10px" href="/toOrder">订单管理</a>
        </c:if>
        <div style="display: inline;float: right"><a class="a2" style="line-height: 50px" href="userInfo?userid=${userid}">${username}</a> | <a href="logout">退出</a></div>

<%--        <div class="box_center_b">--%>
<%--            <ul>--%>
<%--                <li><a class="a2" href="index">首页</a></li>--%>
<%--&lt;%&ndash;                <li><a class="a2" href="login1">登录</a></li>&ndash;%&gt;--%>
<%--&lt;%&ndash;                <li><a class="a2" href="reg1">注册</a></li>&ndash;%&gt;--%>
<%--                <li><a class="a2" href="shoplist">购物车</a></li>--%>
<%--                <li><a class="a2" href="userInfo?userid=${userid}">${username}</a>| <a href="logout">退出</a></li>--%>
<%--            </ul>--%>
<%--        </div>--%>
    </div>
</div>
<div class="box1">
    <form style="text-align: center;" method="post" action="list1">
        <input style="height: 25px;margin-top: 10px; width: 200px;" id="bookname" name="bookname" type="text" placeholder="请输入书名" value=""/>
        <input type="submit" value="搜索"/>
    </form>

</div>
<div class="box2">

    <ul>
        <%--<a href="list?id=1" class="a_book" id="">111</a>--%>
        <c:forEach items="${list}" var="item">
            <a href="list?catalogId=${item.catalogId}" class="a_book"><li>${item.catalogName}</li></a>
        </c:forEach>

    </ul>
    <div class="box2_b">
        <img src="img/index_14.gif" />
        <div class="box2_bb">
<%--            <p>在圣诞来临之际</p>--%>
            <p>本书店为答谢新老朋友</p>
            <p>特举办购物有奖活动</p>
            <p>购物有奖，快快行动吧！</p>
        </div>

    </div>




</div>
<div class="box3">
    <table width="800px" align="center"  class="table table-striped table-hover table-bordered" id="lo-list">
        <c:forEach var="book" items="${book}">

            <tr style="text-align: center">
            <td><img  src="${book.picture}"/></td>
            <td>${book.bookName}</td>
            <td>${book.price}</td>
                <td><input type="hidden" value="${book.bookId}" class="bookid"></td>
            <td><button class="but">加入购物车</button></td>
            </tr>
            <br/>
        </c:forEach>
    </table>


</div>

</body>
</html>
